﻿using System.Collections.Generic;
using Microsoft.Xna.Framework.Content;

namespace TextListLib
{
    public class TextList
    {
        /// <summary>
        /// A generic list of strings.
        /// </summary>
        public List<string> TextData;

        /// <summary>
        /// Our default constructor.
        /// </summary>
        public TextList()
        {
            TextData = new List<string>();
        }

        /// <summary>
        /// Our special constructor that is designed to be called from our
        /// ContentTypeReader. It uses the ContentReader that ContentManager
        /// creates for us to read in the file. The way this is read in must
        /// match the way that the data was written out in the content writer
        /// or you will get bad data (e.g. you read too little data) or an
        /// exception (e.g. you try to read the wrong type of data at the
        /// wrong time).
        /// </summary>
        /// <param name="reader">The ContentReader provided by ContentManager.</param>
        internal TextList(ContentReader reader)
        {
            int count = 0;

            count = reader.ReadInt32();
            TextData = new List<string>(count);
            for (int i = 0; i < count; i++)
            {
                TextData.Add(reader.ReadString());
            }
        }
    }
}